<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="dokuwiki export">

<h1 class="sectionedit1"><a name="geda_library_v3_specification" id="geda_library_v3_specification">gEDA Library v3 Specification</a></h1>
<div class="level1">

</div>
<!-- EDIT1 SECTION "gEDA Library v3 Specification" [1-45] -->
<h2 class="sectionedit2"><a name="rationale" id="rationale">Rationale</a></h2>
<div class="level2">

<p>
The current version (2.x) of the libgeda shared library has a number of defects:
</p>
<ul>
<li class="level1"><div class="li"> Poor separation between public interface and internals, which leads to…</div>
</li>
<li class="level1"><div class="li"> Frequent changes to the <acronym title="Application Programming Interface">API</acronym></div>
</li>
<li class="level1"><div class="li"> <acronym title="Application Programming Interface">API</acronym> contains large amounts of code specific to application internals </div>
</li>
</ul>

<p>
This page is an attempt to itemise in detail what is required of libgeda, and what the interface to it should look like.  This will enable:
</p>
<ul>
<li class="level1"><div class="li"> More rigorous testing of library functions</div>
</li>
<li class="level1"><div class="li"> Creation of language bindings for libgeda</div>
</li>
<li class="level1"><div class="li"> Easier development of other applications for manipulating schematics</div>
</li>
</ul>

</div>
<!-- EDIT2 SECTION "Rationale" [46-643] -->
<h2 class="sectionedit3"><a name="requirements" id="requirements">Requirements</a></h2>
<div class="level2">

</div>
<!-- EDIT3 SECTION "Requirements" [644-669] -->
<h3 class="sectionedit4"><a name="core" id="core">Core</a></h3>
<div class="level3">
<ol>
<li class="level1"><div class="li"> Define data structures for representing schematics</div>
</li>
<li class="level1"><div class="li"> Provide methods for creating and manipulating schematics</div>
</li>
<li class="level1"><div class="li"> Provide methods for reading and storing schematics into files and data streams</div>
</li>
<li class="level1"><div class="li"> Provide access to detailed data on errors and exceptions</div>
</li>
<li class="level1"><div class="li"> Provide a simple interface for configuring libgeda&#039;s behaviour</div>
</li>
</ol>

</div>
<!-- EDIT4 SECTION "Core" [670-1013] -->
<h3 class="sectionedit5"><a name="secondary" id="secondary">Secondary</a></h3>
<div class="level3">
<ol>
<li class="level1"><div class="li"> Make no assumptions about applications which will use the library</div>
</li>
<li class="level1"><div class="li"> Make no assumptions about the compiler or architecture on which the library is being used</div>
</li>
<li class="level1"><div class="li"> Fully reentrant for thread safety</div>
</li>
<li class="level1"><div class="li"> Minimise number of dependency libraries</div>
</li>
<li class="level1"><div class="li"> Detect and gracefully handle multiple instances accessing the same schematic file</div>
</li>
</ol>

</div>
<!-- EDIT5 SECTION "Secondary" [1014-1367] -->
<h2 class="sectionedit6"><a name="coordinate_system" id="coordinate_system">Coordinate System</a></h2>
<div class="level2">

<p>
Because libgeda should “make no assumptions about applications which will use the library,” libgeda should use only “world” coordinates throughout (the same coordinate system as used in the files).
</p>

</div>
<!-- EDIT6 SECTION "Coordinate System" [1368-1659] -->
<h2 class="sectionedit7"><a name="configuration" id="configuration">Configuration</a></h2>
<div class="level2">

<p>
Currently, libgeda relies on an embedded Scheme interpreter (<a href="http://www.gnu.org/software/guile/" class="urlextern" title="http://www.gnu.org/software/guile/"  rel="nofollow">Guile</a>) for configuring settings such as library search paths.  This has a number of pros and cons:
</p>

<p>
Pros:
</p>
<ul>
<li class="level1"><div class="li"> All applications which access libgeda can automatically use the same settings</div>
</li>
<li class="level1"><div class="li"> Arbitrary Scheme code can be used in the configuration process</div>
</li>
</ul>

<p>
Cons:
</p>
<ul>
<li class="level1"><div class="li"> Large &amp; complex dependency</div>
</li>
<li class="level1"><div class="li"> Doesn&#039;t integrate nicely into applications which use e.g. the GNOME or KDE configuration mechanisms</div>
</li>
<li class="level1"><div class="li"> Substantially complicates the creation of graphical user interfaces for configuring library settings</div>
</li>
<li class="level1"><div class="li"> Problems with Guile backward-compatibility in the past</div>
</li>
</ul>

<p>
It might, therefore, make more sense to provide a complete <acronym title="Application Programming Interface">API</acronym> for configuring libgeda, and rely on the application to handle the storage and loading of the configuration.
</p>

</div>
<!-- EDIT7 SECTION "Configuration" [1660-2523] -->
<h2 class="sectionedit8"><a name="dependencies" id="dependencies">Dependencies</a></h2>
<div class="level2">

</div>
<!-- EDIT8 SECTION "Dependencies" [2524-2549] -->
<h3 class="sectionedit9"><a name="glib" id="glib">glib</a></h3>
<div class="level3">

<p>
<a href="http://developer.gnome.org/doc/API/glib/" class="urlextern" title="http://developer.gnome.org/doc/API/glib/"  rel="nofollow">glib</a> provides a very large number of useful features that would make writing and maintaining libgeda easier.  These include:
</p>
<ul>
<li class="level1"><div class="li"> Portable definitions of basic types (although <code>intptr.h</code> does this too, and would probably be preferable)</div>
</li>
<li class="level1"><div class="li"> Doubly- and singly-linked lists, and many other data structures</div>
</li>
<li class="level1"><div class="li"> Plugin loading, memory allocation, threading, IO abstraction, …</div>
</li>
</ul>

<p>
Not having to reinvent the wheel – and letting a much larger project be responsible for optimising and maintaining these features – would make the libgeda code smaller and easier to understand and maintain.  libgeda already uses glib to a certain extent, but using it more extensively in future versions of libgeda does not immediately seem to be a bad idea.
</p>

</div>
<!-- EDIT9 SECTION "glib" [2550-3350] -->
<h3 class="sectionedit10"><a name="gobject" id="gobject">gobject</a></h3>
<div class="level3">

<p>
<a href="http://developer.gnome.org/doc/API/2.0/gobject/" class="urlextern" title="http://developer.gnome.org/doc/API/2.0/gobject/"  rel="nofollow">gobject</a> is an object-oriented programming system in C. It is used extensively in the GTK+ user interface toolkit.  In addition to class-like structures, it provides a signalling system that allows objects to emit, listen for and respond to events.  It is designed to be compatible with the object systems of other languages, and this is one of the chief reasons that so many bindings of GTK+ are available (Python, <acronym title="Practical Extraction and Report Language">Perl</acronym>, .NET, Java, C++, etc).
</p>

<p>
gobject is often considered to be heavyweight, requiring lots of boilerplate code in order to use it effectively.  Its use in libgeda has historically been opposed, though its use in future versions may ease creation of bindings for libgeda in more directly object-oriented languages such as Python, Java or C++.
</p>

<p>
GObject is currently used in libgeda for the GedaList class which wrapps a GList, and provides a notification signal when <acronym title="Application Programming Interface">API</acronym> is used to modify the list.
</p>

</div>
<!-- EDIT10 SECTION "gobject" [3351-4335] -->
<h2 class="sectionedit11"><a name="references" id="references">References</a></h2>
<div class="level2">
<ul>
<li class="level1"><div class="li"> <a href="http://www.unet.univie.ac.at/aix/aixprggd/genprogc/writing_reentrant_thread_safe_code.htm" class="urlextern" title="http://www.unet.univie.ac.at/aix/aixprggd/genprogc/writing_reentrant_thread_safe_code.htm"  rel="nofollow">Writing Reentrant and Thread-Safe Code</a></div>
</li>
</ul>

</div>
<!-- EDIT11 SECTION "References" [4336-] --></div>
</body>
</html>
